<?php

class Nuo_Request_Http extends Nuo_Request_Abstract
{

	/**
	 * constructor
	 * @return void
	 */
	public function __construct()
	{
		$this -> _method = $this->getServer('REQUEST_METHOD', 'GET');

		$path = isset($_REQUEST['_p']) ? $_REQUEST['_p'] : '/';

		$this -> setPath(preg_replace("#(\/)+#", '/', $path));

	}

	/**
	 * @return array
	 */
	public function getParams()
	{
		return $this -> params + $_GET + $_POST;
	}

	/**
	 * @param mixed $key
	 * @param mixed $default Default value to use if key not found
	 * @return mixed
	 */
	public function getParam($key, $default = null)
	{
		if (isset($this -> params[$key]))
		{
			return $this -> params[$key];
		}
		elseif (isset($_GET[$key]))
		{
			return $_GET[$key];
		}
		elseif (isset($_POST[$key]))
		{
			return $_POST[$key];
		}

		return $default;
	}
}
